ExploreByTouchHelper
(SESL variant) ExploreByTouchHelper is a utility class for implementing accessibility support in custom Views that represent a collection of View-like logical items. It extends AccessibilityNodeProviderCompat and simplifies many aspects of providing information to accessibility services and managing accessibility focus.
Clients should override abstract methods on this class and attach it to the host view using setAccessibilityDelegate.
The host view should also override the events in the following code snippet so that the view's logical items are detected properly by the framework:
class MyCustomView extends View {
private MyExploreByTouchHelper mExploreByTouchHelper;
public MyCustomView(Context context, ...) {
...
mExploreByTouchHelper = new MyExploreByTouchHelper(this);
ViewCompat.setAccessibilityDelegate(this, mExploreByTouchHelper);
}
@Override
public boolean dispatchHoverEvent(MotionEvent event) {
return mHelper.dispatchHoverEvent(this, event)
|| super.dispatchHoverEvent(event);
}
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
return mHelper.dispatchKeyEvent(event)
|| super.dispatchKeyEvent(event);
}
@Override
public void onFocusChanged(boolean gainFocus, int direction,
Rect previouslyFocusedRect) {
super.onFocusChanged(gainFocus, direction, previouslyFocusedRect);
mHelper.onFocusChanged(gainFocus, direction, previouslyFocusedRect);
}
}
Content copied to clipboard
Constructors
Functions
Link copied to clipboard
Attempts to clear keyboard focus from a virtual view.
Link copied to clipboard
Delegates hover events from the host view.
Link copied to clipboard
Delegates key events from the host view.
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Returns the virtual view ID for the currently accessibility focused item.
Link copied to clipboard
Link copied to clipboard
Notifies the accessibility framework that the properties of the parent view have changed.
Link copied to clipboard
Notifies the accessibility framework that the properties of a particular item have changed.
Link copied to clipboard
fun onFocusChanged(gainFocus: Boolean, direction: Int, @Nullable previouslyFocusedRect: @Nullable Rect)
Delegates focus changes from the host view.
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Attempts to give keyboard focus to a virtual view.
Link copied to clipboard
Populates an event of the specified type with information about an item and attempts to send it up through the view hierarchy.
Link copied to clipboard
fun setBoundsInScreenFromBoundsInParent(@NonNull node: @NonNull AccessibilityNodeInfoCompat, @NonNull boundsInParent: @NonNull Rect)
Calculates and assigns screen-relative bounds based on bounds in parent.